package component.model;

import java.util.List;
import javax.swing.table.DefaultTableModel;
import model.Jabatan;

/**
 *
 * @author Marlon
 */
public class JabatanTableModel extends DefaultTableModel{
    private List<Jabatan> listJabatan;
    private int listSize;
    
    public JabatanTableModel(List<Jabatan> list) {
        listJabatan = list;
        listSize = list.size();
    }
    
    @Override
    public int getColumnCount() {
        return 3;
    } 
    
    @Override
    public int getRowCount() {
        return listSize;
    }
    
    @Override
    public String getColumnName(int column) {
        switch(column) {
            case 0: return "ID JABATAN ";
            case 1: return "NAMA JABATAN";
            case 2: return "ESELON";
            default: return "";
        }
    }
    
    @Override
    public String getValueAt(int row, int column) {
        Jabatan jabatan = getJabatan(row);
        switch(column) {
            case 0: return jabatan.getId();
            case 1: return jabatan.getJabatan();
            case 2: return jabatan.getEselon();
            default: return "";
        }
    }
    
    public Jabatan getJabatan(int row) {
        return listJabatan.get(row);
    }
}
